<script type="text/javascript">
//自动去除http
function stripHttp() {
	var $domain = $('#domain').val();
    if ($domain.indexOf('http://') >= 0) {
		$domain = $domain.replace('http://', '');
	}
    if ($domain.indexOf('/') >= 0) {
		var $domain = $domain.split('/');
		$domain = $domain[0];
	}
	$domain = $domain.replace(' ', '');
	
	$('#domain').val($domain);
}

//获取META
function getMeta() {
	var $domain = $.trim($('#domain').val());
	if ($domain == '') {
		$('#domain').focus();
		return false;
	}
	
	$('#btn-get-meta').val('正在获取，请稍候...');
	$.ajax({
	   type: "GET",
	   url: "{:U('getMeta')}",
	   data: "domain="+$domain,
	   success: function(result){
		   console.log(result);
			if(result['status'] == 1){
				$('#btn-get-meta').val('重新获取');
				$('#title').val(result['data'].title);$('#name').val(result['data'].title); $('#keywords').val(result['data'].keywords); $('#description').val(result['data'].description); 
			}
	   }
	});
}

//获取IP, PageRank, Sogou PageRank, Alexa
function getWdata() {
	var $domain = $.trim($('#domain').val());
	if ($domain == '') {
		$("#domain").focus();
		return false;
	}
	$('#btn-get-wdata').val('正在获取，请稍候...');
	$.ajax({
	   type: "GET",
	   url: "{:U('getWdata')}",
	   data: "domain="+$domain,
	   success: function(result){
		   console.log(result);
			if(result['status'] == 1){
				$('#btn-get-wdata').val('重新获取');
				$('#ip').val(result['data'].ip); $('#brank').val(result['data'].brank); $('#grank').val(result['data'].grank); $('#srank').val(result['data'].srank); $('#arank').val(result['data'].arank);
			}
	   }
	});
}

$(function(){
	$("#province_id").change(function(){
		var thisProvinceId	= $(this).val();
		$("#city_id").html('<option value="0">-城市-</option>');
		$.ajax({
		   type: "GET",
		   url: "{:U('Region/ajaxGetCity')}",
		   data: "province_id="+thisProvinceId,
		   success: function(result){
				if(result['status'] == 1){
					var option = '';
					for(var i = 0; i < result['data'].length; i++){
						option += '<option value="'+result['data'][i].id+'">'+result['data'][i].name+'</option>';	
					}	
					$("#city_id").html(option);
				}
		   }
		});
	});
});
</script>